package com.admin.action;

import com.admin.bean.KeywordType;
import com.admin.service.KeywordTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 分辨率管理
 *
 * @author:HingLo
 * @create 2017-09-11 15:35
 **/
@Controller
@RequestMapping("/KeywordTpyeAction/admin/")
public class KeywordTpyeAction {


    @Autowired
    private KeywordTypeService keywordTypeService;

    /**
     * 进入到安卓版本权限添加
     * 进入后就直接查询相关的信息
     *
     * @return
     */
    @RequestMapping("keywordType")
    public String inputResolvingAction(HttpServletRequest request) {
        List<KeywordType> list = keywordTypeService.findAllServcie();
        request.setAttribute("dataMap", list);
        return "/WEB-INF/admin/version/keywordTpye";
    }

    /**
     * 进入到添加界面
     *
     * @return
     */
    @RequestMapping("addKeywordType")
    public String inputResolvingAction() {
        return "/WEB-INF/admin/version/addkeywordTpye";
    }

    /**
     * 添加信息
     *
     * @param keywordType
     * @return
     */
    @RequestMapping(value = "submitKeywordType")
    public String addResolvingAction(KeywordType keywordType, HttpServletRequest request) {
        boolean bool = this.keywordTypeService.addResolvingService(keywordType);
        request.setAttribute("bool", bool);
        return "/WEB-INF/admin/version/addkeywordTpye";
    }

    /**
     * 删除相关的信息
     *
     * @param id
     * @return
     */
    @RequestMapping("delKeywordType")
    @ResponseBody
    public String delResolvingAction(String id) {
        return String.valueOf(keywordTypeService.delResolvingService(id));
    }


}
